package com.ruoyi.ncpcs.service.impl;

import java.util.*;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.ruoyi.ncpcs.domain.DataQueryReq;
import org.springframework.stereotype.Service;
import com.ruoyi.ncpcs.mapper.NcpcsInterfaceFieldsMapper;
import com.ruoyi.ncpcs.domain.NcpcsInterfaceFields;
import com.ruoyi.ncpcs.service.INcpcsInterfaceFieldsService;

import javax.annotation.Resource;

/**
 * interfaceFieldsManageService业务层处理
 *
 * @author ruoyi
 * @date 2022-09-25
 */
@Service
@DS("master")
public class NcpcsInterfaceFieldsServiceImpl implements INcpcsInterfaceFieldsService
{
    @Resource
    private NcpcsInterfaceFieldsMapper ncpcsInterfaceFieldsMapper;

    /**
     * 查询interfaceFieldsManage
     *
     * @param id interfaceFieldsManage主键
     * @return interfaceFieldsManage
     */
    @Override
    public NcpcsInterfaceFields selectNcpcsInterfaceFieldsByInterfaceId(Long id)
    {
        return ncpcsInterfaceFieldsMapper.selectNcpcsInterfaceFieldsByInterfaceId(id);
    }

    /**
     * 查询interfaceFieldsManage列表
     *
     * @param ncpcsInterfaceFields interfaceFieldsManage
     * @return interfaceFieldsManage
     */
    @Override
    public List<NcpcsInterfaceFields> selectNcpcsInterfaceFieldsList(NcpcsInterfaceFields ncpcsInterfaceFields)
    {
        return ncpcsInterfaceFieldsMapper.selectNcpcsInterfaceFieldsList(ncpcsInterfaceFields);
    }

    /**
     * 新增interfaceFieldsManage
     *
     * @param ncpcsInterfaceFields interfaceFieldsManage
     * @return 结果
     */
    @Override
    public int insertNcpcsInterfaceFields(NcpcsInterfaceFields ncpcsInterfaceFields)
    {
        return ncpcsInterfaceFieldsMapper.insertNcpcsInterfaceFields(ncpcsInterfaceFields);
    }

    /**
     * 修改interfaceFieldsManage
     *
     * @param ncpcsInterfaceFields interfaceFieldsManage
     * @return 结果
     */
    @Override
    public int updateNcpcsInterfaceFields(NcpcsInterfaceFields ncpcsInterfaceFields)
    {
        return ncpcsInterfaceFieldsMapper.updateNcpcsInterfaceFields(ncpcsInterfaceFields);
    }

    /**
     * 批量删除interfaceFieldsManage
     *
     * @param ids 需要删除的interfaceFieldsManage主键
     * @return 结果
     */
    @Override
    public int deleteNcpcsInterfaceFieldsByInterfaceIds(Long[]  ids)
    {
        return ncpcsInterfaceFieldsMapper.deleteNcpcsInterfaceFieldsByInterfaceIds(ids);
    }

    /**
     * 删除interfaceFieldsManage信息
     *
     * @param id interfaceFieldsManage主键
     * @return 结果
     */
    @Override
    public int deleteNcpcsInterfaceFieldsByInterfaceId(Long id)
    {
        return ncpcsInterfaceFieldsMapper.deleteNcpcsInterfaceFieldsByInterfaceId(id);
    }

    @Override
    public String getBaseQuerySql(String interfaceId){
        return ncpcsInterfaceFieldsMapper.getBaseQuerySql(interfaceId);
    }


    @Override
//    @DS("ncpcs")
    public List<HashMap<String,Object>> getData(DataQueryReq req){
        // 限制每次的最大上传数量
        if(req.getLimitCount()>200){
            req.setLimitCount(200);
        }
        return ncpcsInterfaceFieldsMapper.getData(req);
    }

    @Override
    public String getQueryTable(String interfaceId) {
        return ncpcsInterfaceFieldsMapper.getQueryTable(interfaceId);
    }

    @Override
    public String getPkColumn(String interfaceId) {
        return ncpcsInterfaceFieldsMapper.getPkColumn(interfaceId);
    }

    @Override
    public void dealUploadSuccess(Set uploadSuccess,String tableName) {
        List list = Arrays.asList(uploadSuccess.toArray());
        ncpcsInterfaceFieldsMapper.updateSuccess(list);
    }

    @Override
    public void dealUploadFail(Set uploadFail,String tableName) {
        List list = Arrays.asList(uploadFail.toArray());
        ncpcsInterfaceFieldsMapper.updateFail(list);
    }

}
